package com.real8.romemp.client.place;

import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceTokenizer;

public class LabourAllocationPlace extends Place {
	public enum EMenuSelection {
		NONE, ARMY, NAVY, MERCHANTS, ARTISANS, SHIP_BUILDERS
	}

	private EMenuSelection menuOption;

	public LabourAllocationPlace() {
		this(EMenuSelection.NONE);
	}

	public LabourAllocationPlace(EMenuSelection menuOption) {
		this.menuOption = menuOption;
	}

	public EMenuSelection getMenuOption() {
		return menuOption;
	}

	public static class Tokenizer implements
			PlaceTokenizer<LabourAllocationPlace> {
		@Override
		public String getToken(LabourAllocationPlace place) {
			return place.getMenuOption().toString();
		}

		@Override
		public LabourAllocationPlace getPlace(String token) {
			// determine menuOption
			EMenuSelection menuOption = EMenuSelection.NONE;
			if (token.equalsIgnoreCase(EMenuSelection.ARMY.toString())) {
				menuOption = EMenuSelection.ARMY;
			} else if (token.equalsIgnoreCase(EMenuSelection.NAVY.toString())) {
				menuOption = EMenuSelection.NAVY;
			} else if (token.equalsIgnoreCase(EMenuSelection.MERCHANTS
					.toString())) {
				menuOption = EMenuSelection.MERCHANTS;
			} else if (token.equalsIgnoreCase(EMenuSelection.ARTISANS
					.toString())) {
				menuOption = EMenuSelection.ARTISANS;
			} else if (token.equalsIgnoreCase(EMenuSelection.SHIP_BUILDERS
					.toString())) {
				menuOption = EMenuSelection.SHIP_BUILDERS;
			}

			// end
			return new LabourAllocationPlace(menuOption);
		}
	}
}
